package com.example.studentmanagement2.controller;

import com.example.studentmanagement2.service.StatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/stats")
public class StatsController {
    @Autowired
    private StatsService statsService;

    @GetMapping("/class-avg")
    public ResponseEntity<?> getClassAverages(@RequestParam String className) {
        return ResponseEntity.ok(statsService.getClassAverages(className));
    }
}